<?php
#region CODE
use Gotcha\App\Extensions\GotchaRoutingExtension;
use Gotcha\App\Framework\Controller;
use Modules\JasminumCalendarReservations\Controllers\DefaultController;

$framework = new Controller();
$controller = new DefaultController();
$currentUrl = new GotchaRoutingExtension();
#endregion
?>
<header>
    <h2 style="margin: 10px 0;">Zarezerwuj salę</h2>
</header>
<div id="notification">
    <?php if(isset($_GET['error']) && $_GET['error'] == 1): ?>
        <div class="error">Musisz wypełnić wszystkie pola!</div>
    <?php endif; ?>
    <?php if(isset($_GET['error']) && $_GET['error'] == 2): ?>
        <div class="error">Niepoprawny typ sali!</div>
    <?php endif; ?>
    <?php if(isset($_GET['error']) && $_GET['error'] == 3): ?>
        <div class="error">Musisz podać poprawny adres email!</div>
    <?php endif; ?>
</div>
<section id="jasminum-calendar-reservations">
    <form method="post" action="<?= $framework->UrlContent('/JasminumCalendarReservations/Send') ?>">
        <fieldset>
            <div id="HallTypes">
                <label for="HallType">Sala:</label>
                <select name="HallType" id="HallType">
                    <option value="-1" selected="selected">--- Wybierz opcję ---</option>
                    <?php foreach($controller->getHalls() as $hallName => $hall): ?>
                        <option value="<?php echo $hall; ?>"><?php echo $hallName; ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
            <div id="ReservationInfo">
                <label for="Firstname">Imie</label>
                <input type="text" name="Firstname" id="Firstname">
                <label for="Lastname">Nazwisko</label>
                <input type="text" name="Lastname" id="Lastname">
                <label for="Phone">Telefon</label>
                <input type="text" name="Phone" id="Phone">
                <label for="Email">Adres e-mail</label>
                <input type="text" name="Email" id="Email">
                <label for="DateFrom">Data od</label>
                <input type="text" name="DateFrom" id="DateFrom" placeholder="RRRR-MM-DD" style="width: 93px;" maxlength="10">
                <div class="clearfix"></div>
                <label for="DateTo">Data do</label>
                <input type="text" name="DateTo" id="DateTo" placeholder="RRRR-MM-DD" style="width: 93px;" maxlength="10">
                <div class="clearfix"></div>
                <button>Wyślij</button>
                <input type="hidden" name="ReturnURL" value="<?= $currentUrl; ?>">
            </div>
        </fieldset>
    </form>
</section>
<script>
    var optionsType = $("#RoomType").html();

    // Reset options
    $('#HallTypes').find('options').each(function() {
        if($(this).val() == '-1') {
            $(this).attr('selected', 'selected');
        }
    });

    /*$('#RoomColor').change(function() {
     switch ($(this).val()) {
     case '-1':
     $('#RoomTypes').fadeOut();
     $('#ReservationInfo').fadeOut();
     break;
     case '0':
     $('#RoomType').html(optionsType);
     // Hide invalid options
     $('#RoomType').find('option').each(function() {
     // Reset visibility
     $(this).show();

     // Hide
     if($(this).val() == '2') {
     $(this).remove();
     }
     });
     $('#RoomTypes').fadeIn();
     break;
     case '1':
     $('#RoomType').html(optionsType);
     // Hide invalid options
     $('#RoomType').find('option').each(function() {
     // Reset visibility
     $(this).show();

     // Hide
     if($(this).val() == '1') {
     $(this).remove();
     }
     });
     $('#RoomTypes').fadeIn();
     break;
     case '2':
     $('#RoomType').html(optionsType);
     // Hide invalid options
     $('#RoomType').find('option').each(function() {
     // Reset visibility
     $(this).show();

     // Hide
     if($(this).val() == '1' || $(this).val() == '2') {
     $(this).remove();
     }
     });
     $('#RoomTypes').fadeIn();
     break;
     }
     });*/

    $('#HallTypes').change(function() {
        if($(this).val() != '-1') {
            $('#ReservationInfo').fadeIn();
        } else {
            $('#ReservationInfo').fadeOut();
        }
    });
</script>